/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.expert.dao.ExpertExperienceBasicDao;
import com.chlitina.store.modules.expert.entity.ExpertExperienceBasic;

/**
 * 方案范围
 * @author liujiang
 * @version 2013-06-09
 */
@Component
@Transactional(readOnly = true)
public class ExpertExperienceBasicService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(ExpertExperienceBasicService.class);
	
	@Autowired
	private ExpertExperienceBasicDao expertExperienceBasicDao;
	
	public long check(int min, int max) {
		return expertExperienceBasicDao.check(min, max);
	}
	
	public long check(int min, int max, Long oldMin, Long oldMax) {
		return expertExperienceBasicDao.check(min, max, oldMin, oldMax);
	}
	
	public List<ExpertExperienceBasic> getMiddle(int middleId) {
		return expertExperienceBasicDao.findByMiddle(middleId);
	}
	
	public ExpertExperienceBasic getByPK(Long min, Long max) {
		return expertExperienceBasicDao.findByPK(min, max);
	}
	
	public List<ExpertExperienceBasic> getBySolution(Long solution_id) {
		return expertExperienceBasicDao.getBySolution(solution_id);
	}
	
	public Page<ExpertExperienceBasic> find(Page<ExpertExperienceBasic> page, ExpertExperienceBasic expertExperienceBasic) {
		DetachedCriteria dc = expertExperienceBasicDao.createDetachedCriteria();
		dc.addOrder(Order.asc("min_value"));
		return expertExperienceBasicDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(ExpertExperienceBasic expertExperienceBasic) {
		expertExperienceBasicDao.save(expertExperienceBasic);
	}
	
	@Transactional(readOnly = false)
	public void delete(ExpertExperienceBasic expertExperienceBasic) {
		expertExperienceBasicDao.delete(expertExperienceBasic);
	}
	
}
